@echo off
chcp 65001
title Supermarket Management System Services

:: 设置Java路径
set JAVA_HOME=D:\CodeTool\compile\jdk22
set PATH=%JAVA_HOME%\bin;%PATH%

:: 设置应用程序路径
cd /d "%~dp0"
call mvn clean package -DskipTests
call mvn dependency:copy-dependencies

:: 等待Nacos完全启动
echo 请确保Nacos已经启动并且正在运行(localhost:8848)...
timeout /t 5

:: 启动网关服务
echo Starting Gateway Service...
start "Gateway Service" java -Dfile.encoding=UTF-8 -Dspring.profiles.active=gateway -Dspring.cloud.bootstrap.enabled=true -cp target/classes;target/dependency/* top.skihub.TliasWebSmartshoppingApplication

:: 等待网关服务启动
timeout /t 5

:: 启动两个商品服务实例
echo Starting Goods Services...
start "Goods Service 1" java -Dfile.encoding=UTF-8 -Dspring.profiles.active=goods -Dspring.cloud.bootstrap.enabled=true -cp target/classes;target/dependency/* top.skihub.TliasWebSmartshoppingApplication
timeout /t 2
start "Goods Service 2" java -Dfile.encoding=UTF-8 -Dspring.profiles.active=goods -Dspring.cloud.bootstrap.enabled=true -cp target/classes;target/dependency/* top.skihub.TliasWebSmartshoppingApplication

:: 启动两个购物车服务实例
echo Starting Cart Services...
start "Cart Service 1" java -Dfile.encoding=UTF-8 -Dspring.profiles.active=cart -Dspring.cloud.bootstrap.enabled=true -cp target/classes;target/dependency/* top.skihub.TliasWebSmartshoppingApplication
timeout /t 2
start "Cart Service 2" java -Dfile.encoding=UTF-8 -Dspring.profiles.active=cart -Dspring.cloud.bootstrap.enabled=true -cp target/classes;target/dependency/* top.skihub.TliasWebSmartshoppingApplication

echo All services started. Check Nacos console (http://localhost:8848/nacos) to verify service registration.
echo Press any key to exit...
pause
